﻿using Microsoft.WowAddonStudio.FrameXml.Serialization.LayoutFrames;
using NUnit.Framework;

namespace Microsoft.WowAddonStudio.FrameXml.Serialization.Tests
{
	[TestFixture]
	public class ButtonTest : SerializationTestBase<Button>
	{
		[Test]
		public void BasicTest()
		{
			InitializeTestEntity("Simple/Button.xml");

			Assert.AreEqual("TestButton", TestEntity.Name);
            Assert.IsNotNull(TestEntity.SizeDimension);
			Assert.IsNotNull(TestEntity.Anchors);
			Assert.IsNotNull(TestEntity.HitRectInset);
			Assert.IsNotNull(TestEntity.ScriptContainer);
		}

        /// <summary>
        /// Gets the entity to be tested from a <see cref="Ui"/> instance.
        /// </summary>
        /// <param name="ui">The ui instance.</param>
        /// <returns>
        /// An instance of the <typeparamref name="TSerializationObject"/> class.
        /// </returns>
		protected override Button GetTestEntity(Ui ui)
		{
			Assert.IsNotNull(ui.LayoutFrames);
			Assert.AreEqual(1, ui.LayoutFrames.Count);

			// Ui/Button[0]
			Assert.IsTrue(ui.LayoutFrames[0] is Button);
			return (Button) ui.LayoutFrames[0];
		}
	}
}